package io;
import java.io.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 *
 * @author Keo Sovann
 */
public class Io {

    public static void main(String[] args) throws IOException {
        File filein = new File("D:\\testread.txt");
        FileReader fin = new FileReader(filein);
        BufferedReader in = new BufferedReader(fin);
        String str;
        FileWriter fw;
      try {
            fw = new FileWriter("D:\\testwrite.txt");
            } catch (IOException exc) {
            System.out.println("Error!");
            return;
        }
         str = in.readLine();
         System.out.println(str);
         fw.write(str + ' ');
         System.out.println("\n*****\n" + str + "\nwritten to file output");
      fw.close();
      }
   }
